﻿using UnityEngine;
using System.Collections;

public class Singleton<T> where T : class, new () {
	static T _instance = null;
	static object lockObj = new object ();

	public static T Instance {
		get {
			lock (lockObj) {
				if (null == _instance) {
					_instance = new T ();
				}
				
				return _instance;
			}
		}
	}

	public static void Release () {
		_instance = null;
		lockObj = null;
	}

    static public bool IsValid () {
        return (Singleton<T>._instance != null);
    }

}
